// 添加商品的请求
// 获取商品分类/productAttribute/category/list/withAttr
import http from "./request";
// 商品分类
const productAttribute = (): PRES<IaddProductList[]> =>
  http.get("/productCategory/list/withChildren");

// 商品品牌  /brand/list?pageNum=1&pageSize=100
const brandList = (): PRES<IbrandList> =>
  http.get(`brand/list?pageNum=1&pageSize=100`);

// 属性类型
const productCategoryList = (): PRES<ICategoryList> =>
  http.get(`/productAttribute/category/list?pageNum=1&pageSize=100`);

// 下拉之后请求回来把数据渲染上去productAttribute/list
const productAttributeList = (params: any): PRES<productAttributeListtype> =>
  http.get(
    `productAttribute/list/${params.id}?pageNum=${params.pageNum}&pageSize=${params.pageSize}&type=${params.type}`
  );
const productAttributeListType = (
  params: any
): PRES<productAttributeListtype> =>
  http.get(
    `productAttribute/list/${params.id}?pageNum=${params.pageNum}&pageSize=${params.pageSize}&type=${params.type}`
  );

// /subject/listAll
// 获取全部商品专题
const subjectListAll = (): PRES<IprefrenceArea[]> =>
  http.get("/subject/listAll");
// 获取全部商品的优选 /prefrenceArea/listAll
const prefrenceAreaListAll = (): PRES<IprefrenceAreaList[]> =>
  http.get("/prefrenceArea/listAll");

// 添加商品
const productCreate = (params: any) => http.post("/product/create", params);
export {
  productAttribute,
  brandList,
  productCategoryList,
  productAttributeList,
  productAttributeListType,
  subjectListAll,
  prefrenceAreaListAll,
  productCreate,
};
